﻿using System;
using System.Web;
using System.Data;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;

/// <summary>
/// systemcatalog 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class systemcatalog : System.Web.Services.WebService
{

    public systemcatalog()
    {

        //如果使用设计的组件，请取消注释以下行 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string SystemCatalogTree(string catalogId)
    {
        string HTML_TABLE = "<ul class=\"simpleTree\">{0}</ul>";
        string HTML_ITEMS = "<li class=\"simpleTree\" itemId=\"{0}\"><span class=\"simpleTree\"><a class=\"simpleTree\" href=\"javascript:mouseDown(this);\"><img class=\"simpleTree\" src=\"../_imgs/ico_Plus.gif\" alt=\"已折叠，单击即可展开\" /></a><input type=\"radio\" class=\"hiddenRadio\" name=\"subjectTree\" id=\"{0}\" /><label class=\"TreeItem\" for=\"{0}\">{1}</label></span></li>";

        DataTable dt = new DataTable();

        string strTreeNodeHTML = "";
        try
        {
            dt = BLL.CommonBLL.Select("System_CatalogBase", " * ", " AND ParentId = " + catalogId + " AND DeletionStateCode = 0 ORDER BY Sort ASC ");

            if (dt == null || dt.Rows.Count <=0)
                return "";
            
            foreach (DataRow dr in dt.Select(""))
            {
                strTreeNodeHTML += string.Format(HTML_ITEMS, dr["CatalogId"].ToString(), Common.Utils.HtmlEncode(dr["CatalogName"].ToString()));
            }
            dt.Dispose();
        }
        catch
        { }
        finally
        {
            dt.Dispose();
        }
        string res = "";
        if (strTreeNodeHTML.Trim() != "")
        {
            res = string.Format(HTML_TABLE, strTreeNodeHTML);
        }
        return res;
    }
}

